/* -----------------------------------------------------------------------
 *
 * Include the following lines in your makefile:
 *
 * unittest1: unittest1.c dominion.o rngs.o
 *      gcc -o unittest1 -g  unittest1.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */


#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"


// set NOISY_TEST to 0 to remove printfs from output
//#define NOISY_TEST 1

int main() {
    int i;
    int seed = 1000;
    int numPlayer = 2;
    int p, r, handCount;
    int k[10] = {adventurer, council_room, feast, gardens, mine
        , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    int maxHandCount = 5;
    
    printf ("TESTING drawCard():\n");
    
    memset(&G, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
    G.handCount[p] = 0;         // set the number of cards on hand
    
    for (p = 0; p < numPlayer; p++)
    {
        for (handCount = 0; handCount < maxHandCount; handCount++)
        {
	        //#if (NOISY_TEST == 1)
                printf("Test player %d with %d cards in hand.\n", p, handCount);
                //#endif

                drawCard(p, &G);
            
                //#if (NOISY_TEST == 1)
                printf("G.handCount = %d, expected = %d\n", G.handCount[p], handCount + 1);
                //#endif
                assert(G.handCount[p] == handCount + 1); // check if the handCount is corrent
        }
    }
    
    printf("All tests passed!\n");
    
    return 0;
}
